var floaterTimer = 0;

function floater(t, url) {
    clearFloater();
    const body = document.getElementsByTagName('body')[0];
    floaterTimer = setInterval(floaterStart, 500);

    function floaterStart() {
        var elem = document.createElement('img');
        elem.setAttribute("class", "floater");
        elem.src = url;
        elem.style.width = randomFN(30, 37) + 'px';
        elem.style.animation = 'floaterMove ' + t + 's ease-in forwards';
        elem.style.left = randomFN(0, 800) + 'px';
        elem.style.transform = "rotate(" + randomFN(-30, 30) + "deg)";
        body.appendChild(elem);
        setTimeout(function () {
            body.removeChild(elem);
        }, t * 1000)
    }
    function randomFN(min, max) {
        return parseInt(Math.random() * (max - min) + min);
    }
}

function clearFloater(){
    if(floaterTimer) {
        clearInterval(floaterTimer);
        floaterTimer = 0;
    }
    $("body").remove(".floater");
}